<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" href="skin/base.css">
<link rel="stylesheet" href="skin/form.css">
<link rel="stylesheet" href="skin/btn.css">
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body ontouchstart>
<div id="main" class="box-ver box">
  <div id="header">
  	<div class="title">
  		<span class="l icon back" ontouchstart="zy_touch('act')" onclick="uexWindow.close(-1);"></span>
		<span class="txt">登录</span>
	</div>
  </div>
  <div id="content">
    <div class="form">
    	<div class="items">
            <div class="item">
            	<div class="txt"> <input type="text" id="username" name="username" maxlength="12" placeholder="请输入2-20位之间的用户名" /></div>
            </div>
            <div class="item">
            	<div class="txt"> <input type="password" name="password" id="password" maxlength="20" placeholder="请输入6-20位之间的登录密码" /></div>
            </div>
        </div>
		
		
		
    
      <div class="btn">
        <div class="button" ontouchstart="zy_touch('down')" onclick="login('login');">登录</div>
      </div>
      <p class='p1 t-c'> 
	  <span ontouchstart="zy_touch('down')" onclick="uexWindow.open('reg','0','reg.html',12,'', '',0);">注册</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span onclick="uexWindow.open('user_forgot_pass','0','user_forgot_pass.html',12,'', '',0);">忘记密码？</span> 
	  </p>
      
          <div class="btn">
            <div class="tlogin" ontouchstart="zy_touch('down')" onclick="login('qqweibo');"><img src="skin/images/oauth/qqweibo_tie.png" /><span>微博登录</span></div>
			<div class="sp"></div>
			<div class="tlogin" ontouchstart="zy_touch('down')" onclick="login('sina');"><img src="skin/images/oauth/sina_tie.png" /><span>微博登录</span></div>
          </div>
		  
		  
	  
    </div>
  </div>
</div>
</body>
<script>
    	zy_init();
		var type = '';
		function ok(){
			var url = localStorage['login'];
			if(typeof(url)!= "undefined"){
				uexWindow.evaluatePopoverScript(url,'content','oklogin("登录成功~");');
			}
			localStorage.removeItem("login");
			uexWindow.toast("0","5","登录成功~!",2000);
			uexWindow.close(0);
		}
		
		
		function GetInfo(){
			 uexDevice.cbGetInfo = function(opId, dataType, data){
				alert(data);
	            if(data){
					alert('data:'+data);
	                var device = JSON.parse(data);
					
					alert('uexWidgetOne.getPlatform():'+uexWidgetOne.getPlatform());
	            }
	        }
	
			alert("uexDevice.getInfo('1');");
	        uexDevice.getInfo('1');
		}
		
		function login(str){
			type=str;
			if (str == "login") {
				var username = $$('username').value;
				if (username.length < 2 || username.length >20) {
					uexWindow.alert('错误提示', '请输入2-20位之间的用户名~', '关闭');
					return false;
				}
				var password = $$('password').value;
				if (password.length < 6 || password.length >20) {
					uexWindow.alert('错误提示', '请输入6-20位之间的登录密码~', '关闭');
					return false;
				}
				uexWindow.toast(1, 5, '提交中...', 0);
				var url = app_path + 'index.php?m=iapp&c=user&a=login';
				uexXmlHttpMgr.open(99, 'post', url, "8000");
				uexXmlHttpMgr.setPostData(99, '0', 'username', username);
				uexXmlHttpMgr.setPostData(99, '0', 'password', password);
				uexXmlHttpMgr.send(99);
			}else if(str=="qqweibo"){
				var wkey=l_connect['qqweibo'];
				var cburl=app_path+'bind.html';
				var url='https://open.t.qq.com/cgi-bin/oauth2/authorize?client_id='+wkey+'&response_type=token&redirect_uri='+encodeURIComponent(cburl)+'&wap=2';
				
				var e = $$("header");
				var y = e.offsetHeight;
				var s = window.getComputedStyle($$("content"),null);
				uexWindow.onOAuthInfo = onOAuth;
				uexWindow.openPopover('content','0',url,'',0,int(y),int(s.width),int(s.height),int(s.fontSize),'1');
			}else if(str=="sina"){
				var wkey=l_connect['sina'];
				var cburl=app_path+'bind.html';
				url = 'https://api.weibo.com/oauth2/authorize?client_id='+wkey+'&response_type=token&redirect_uri='+encodeURIComponent(cburl)+'&display=mobile&forcelogin=true';
				var e = $$("header");
				var y = e.offsetHeight;
				var s = window.getComputedStyle($$("content"),null);
				uexWindow.onOAuthInfo = onOAuth;
				uexWindow.openPopover('content','0',url,'',0,int(y),int(s.width),int(s.height),int(s.fontSize),'1');
			}
		}

		function onOAuth(winName, url){
			if (url.indexOf("expires_in") > 0) {
				uexWindow.toast(1, 5, '绑定中...', 0);
				var srt =url.split("#");
				var urls = app_path+'index.php?m=iapp&c=user&a=tp_login&type='+type+'&'+srt[1];
				uexXmlHttpMgr.open(1,'get',urls,"8000");
				uexXmlHttpMgr.send(1);
			}
		}
				
		window.uexOnload = function(type){
			if (!type) {
				uexXmlHttpMgr.onData = function(opId, status, data){
					uexXmlHttpMgr.close(opId);
					uexWindow.closeToast();
					if (status == 1) {
						data = JSON.parse(data);
						if(opId == 99) {
							if (data['success'] == 'OK') {
								logout();
								localStorage['u_id'] = data['data']['userid'];
								localStorage['u_nick'] = data['data']['nick'];
								localStorage['u_acctoken'] = data['data']['acctoken'];
								localStorage['u_mobile'] = data['data']['mobile'];
								localStorage['u_integral'] = data['data']['integral'];
								
								var share = data['data']['share'];
								if (share.length > 0) {
									for (k in share) {
										localStorage[share[k]['name'] + '_connectid'] = share[k]['connectid'];
									}
								}
								ok();
							}else if (data['success'] == 'NOUSERNAME') {
								uexWindow.toast("0","5","账号不存在~!",2000);
							}else {
								uexWindow.toast("0","5","账号或密码不正确~!",2000);
							}
						}else if(opId == 1){
							uexWindow.closePopover('content');
							if(data['success']=='OK'){
								logout();
								localStorage['u_id'] = data['data']['userid'];
								localStorage['u_nick'] = data['data']['nick'];
								localStorage['u_acctoken'] = data['data']['acctoken'];
								localStorage['u_mobile'] = data['data']['mobile'];
								localStorage['u_integral'] = data['data']['integral'];
								
								var share = data['data']['share'];
								if (share.length > 0) {
									for (k in share) {
										localStorage[share[k]['name'] + '_connectid'] = share[k]['connectid'];
									}
								}
								ok();
							}else{
								uexWindow.toast("0","5","登录失败~",2000);
							}
						}
					}else if(status==-1){
						if (opId == 1) {
							uexWindow.closePopover('content');
						}
						uexWindow.toast("0","5","登录超时~",2000);
					}
				}
			}
		}
    </script>
</html>